import {ExampleFormComponent} from './form/example-form.component';
import {CommonPage} from '../common-page';
import {DhlTableComponent} from '../../../shared/components/dhlcomponent/table/dhl-table.component';
import {CookieHelper} from '../../../shared/utils';
import {NzModalService} from 'ng-zorro-antd/modal';
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';

@Component({
  templateUrl: './example.component.html'
})
export class ExampleComponent extends CommonPage implements OnInit {


  test;
  userNo;
  name;
  name2;
  name3;
  name4;
  name5;
  name6;
  nameShow = true;
  siteShow = true;
  age = '年龄';
  age1 = '年龄1';
  age2 = '年龄2';
  nametipe = '输入名字';
  commponent = ExampleFormComponent;
  formTitle = `{name}-ContactUserComponent`;
  colWidths = [[5, 5, 10]];
  options = [{name: '1', value: '1'}, {name: '2', value: '2'}];
  datas = [
    {name: '账号1', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号2', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号3', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号4', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号5', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号6', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号7', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号8', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号9', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号10', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号11', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号12', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号13', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号14', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号1', site: 'code', depart: '公司1', status: '启用', count: '20000'},
    {name: '账号2', site: 'code', depart: '公司2', status: '停用', count: '40000'}
  ];


  showExport = {
    fileName: '用户列表',
    trailDate: true
  };

  listOfData = [
    {
      key: '1',
      name: 'John Brown',
      age: 32,
      address: 'New York'
    },
    {
      key: '2',
      name: 'Jim Green',
      age: 40,
      address: 'London'
    }
  ];

  single = [
    {
      name: 'Germany',
      value: 8940000
    },
    {
      name: 'USA',
      value: 5000000
    },
    {
      name: 'France',
      value: 7200000
    },
    {
      name: 'UK',
      value: 6200000
    },
    {
      name: 'Italy',
      value: 4200000
    },
    {
      name: 'Spain',
      value: 8200000
    }
  ];

  view = [700, 300];
  colorScheme = {
    domain: ['#76BD22', '#AAE3F5', '#FFE57F', '#A17EA7', '#5AA454', '#E44D25', '#CFC0BB', '#7aa3e5', '#a8385d', '#aae3f5']
  };
  societyTrade;
  contryDebt;
  process;
  mult = [
    {
      name: 'Germany',
      series: [
        {
          name: '1990',
          value: 62000000
        },
        {
          name: '2010',
          value: 73000000
        },
        {
          name: '2011',
          value: 89400000
        }
      ]
    },

    {
      name: 'USA',
      series: [
        {
          name: '1990',
          value: 250000000
        },
        {
          name: '2010',
          value: 309000000
        },
        {
          name: '2011',
          value: 311000000
        }
      ]
    },

    {
      name: 'France',
      series: [
        {
          name: '1990',
          value: 58000000
        },
        {
          name: '2010',
          value: 50000020
        },
        {
          name: '2011',
          value: 58000000
        }
      ]
    },
    {
      name: 'UK',
      series: [
        {
          name: '1990',
          value: 57000000
        },
        {
          name: '2010',
          value: 62000000
        }
      ]
    }
  ];
  showXAxis = true;
  showYAxis = true;
  showLegend = true;
  basicAspect = 'rmb_loan';

  @ViewChild('queryLocationRef', {static: true, read: ElementRef}) queryLocationRef: ElementRef;
  @ViewChild('table', {static: true, read: DhlTableComponent}) tableRef: DhlTableComponent;


  constructor(private modal: NzModalService) {
    super();
  }

  ngOnInit() {

    /*this.requestService.get(`/case/debt/getline`, {basicAspect: this.basicAspect}).subscribe((data) => {
      this.process = data;
    });

    this.requestService.get(`/case/debt/getline`, {basicAspect: 'contry_debt'}).subscribe((data) => {
      this.contryDebt = data;
    });

    this.requestService.get(`/case/debt/getline`, {basicAspect: 'society_trade'}).subscribe((data) => {
      this.contryDebt = data;
    });*/

    this.nameShow = false;
  }


  testBigData() {
    const row = {
      k: 's',
      k1: 's',
      k2: 's',
      k3: 's',
      k4: 's',
      k5: 's',
      k6: 's',
      k7: 's',
      k8: 's',
      k9: 's',
      k11: 's',
      mm: [1, 2, 3],
      ss: [{
        k: 's',
        mm: [1, 2, 3],
      }, {
        k: 's',
        mm: [1, 2, 3],
      }]
    };
    const total = [];

    for (let i = 0; i < 12000; i++) {
      total.push(row);
    }

    this.requestService.requestPost('/bps/redletterdetail/test?', {totals: total}).subscribe();
  }

  clickFun() {
    this.name2 = this.name2 + '1';
    this.name = this.name + '1';
    console.log(this.test, this.name, this.name2, this.name3, this.name4, this.name5, this.name6, this.age, this.age1, this.age2);
  }

  valueChange({detail}) {
    console.log('input change value', detail, this.name);
  }

  export1({detail}) {
    this.nameShow = !this.nameShow;
    console.log('export1 click', detail);
  }

  export2({detail}) {
    this.siteShow = !this.siteShow;
    console.log('export2 click', detail);
  }

  export3({detail}) {
    console.log('export3 click', detail);
  }

  export4({detail}) {
    console.log('export4 click', detail);
  }

  notify() {
    this.messageService.notifyError('text');
  }


  info() {
    this.messageService.info('error');
  }

  success() {
    this.messageService.success('success');
  }

  error() {
    this.messageService.error('error');
  }


  login() {
    this.router.navigate([`/example/b`]);
  }

  cleanCookie() {
    CookieHelper.clearCookies();
  }

  sqlinject() {
    this.requestService.post(`monitor/activeacct`).subscribe();
  }

  keydown() {
    this.options = [{name: '3', value: '3'}, {name: '2', value: '2'}];
  }

  createTplModal(): void {
    this.windowService.openWindow({
      component: ExampleFormComponent,
      title: '提示',
      width: 300,
      data: {name: 'msg'}
    });

  }

  query() {
    this.requestService.get(`/case/debt/getline`, {basicAspect: this.basicAspect}).subscribe((data) => {
      this.process = data;
    });
  }
}




